<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <body>
    <script>
	    function show(){
		  var n = window.prompt("请输入一个判断是否为水仙花数的三位正整数");
		  var m = cheek(n);  //调用判断水仙花数的函数
		  if(m){
		      alert("输入的"+n+"是水仙花数");
		  }else{
              alert("输入的"+n+"不是水仙花数");
		  }
		}
		function cheek(n){ 
		  g = parseInt(n % 10);
          s = parseInt(n / 10) % 10;
          b = parseInt(n / 100);
		  var num = Math.pow(g,3) + Math.pow(s,3) + Math.pow(b,3);//求分解出的每位数的三次方之和
		  if(n == num){ 
		     return true;
		  }else{
		     return false;
		  }
		}
		show();
	</script>
 </body>
</html>
